#!/usr/bin/env python
# coding: utf-8

# In[14]:


def calRoot2():
    print("The root of 2 is ",1.414)
    return 0


# In[15]:


calRoot2()


# In[23]:


def people(name,age):
    print(name,' is',age,'years old')
    return 0


# In[24]:


people('WXS',250)


# In[28]:


dogname = "Wang Xiansen"
dogage = 250


# In[29]:


people(dogname,dogage)


# In[30]:


if 1 > 0 :
    print("True")


# In[33]:


if 1 < 0 :
    print("True")
else:
    print("False")


# In[35]:


dogage = 18
if dogage > 40:
    print("WXS is turly a dog")
elif dogage <18:
    print("WXS is a baby dog")
else:
    print("ZKX is handsome")


# In[36]:


for i in dogname:
    print(i)


# In[37]:


myList = [1, 2, 3, 4, 5]


# In[ ]:


for num in myList:
    print(num)


# In[39]:


i = 1
while i <= 10:
    print(i)
    i += 1


# In[40]:


def calXnew(Xold):
    return 1/Xold + Xold / 2


# In[41]:


Xold = 10


# In[42]:


Xnew = calXnew(Xold)


# In[43]:


print(Xnew)


# In[ ]:


Xold = Xnew
Xnew = calXnew(Xold)
print(Xnew)


# In[22]:


def calXnew(Xold):
    return 1/Xold + Xold / 2
Xold = 100
Xnew = 0
i = 0

while True > 0.0000001:
    Xnew = calXnew(Xold)
    difference = abs(Xnew - Xold)
    Xold = Xnew
    i += 1
    print(i,Xnew)
    if difference < 0.0000001:
        break
    


# In[ ]:




